﻿using Sys.Common;
using Sys.Core.House;
using Sys.Core.Tour;
using Sys.Model;
using Sys.Model.BpamsModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Sale : System.Web.UI.Page
{
    #region 原设计（从数据库读取相关数据）
    //public HouseSale model { get; set; }

    //protected void Page_Load(object sender, EventArgs e)
    //{
    //    if (!IsPostBack)
    //    {
    //        string id = Request.QueryString["id"];

    //        if (!string.IsNullOrEmpty(id))
    //        {
    //            model = SaleBll.I.GetByKey(id);

    //            if (model != null)
    //            {
    //                Home mas = Master as Home;

    //                string des = StringHelper.NoHTML(model.Content);

    //                mas.SetHead(model.Name, model.Name, StringHelper.CutString(des, 100));
    //            }
    //            else { model = new HouseSale(); }
    //        }
    //        else { model = new HouseSale(); }
    //    }
    //}

    //public string GetImages(string id)
    //{
    //    System.Text.StringBuilder sb = new System.Text.StringBuilder();

    //    sb.Append("<ul class='listPic4'>");

    //    var list = ImageBll.I.GetImages("Sale", id);

    //    foreach (var item in list)
    //    {
    //        sb.Append("<li>");
    //        sb.Append("<a href='#' class='img'><img src='userfiles/sale/default/" + item.Img + "'/></a>");
    //        sb.Append("</li>");
    //    }

    //    sb.Append("</ul>");

    //    return sb.ToString();
    //}
    #endregion

    #region 新设计（从BPAMS读取相关数据）
    public Bpams_House model { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                model = BpamsBll.Instance.GetHouse(id);

                if (model != null)
                {
                    Home mas = Master as Home;

                    string des = StringHelper.NoHTML(model.Remark);

                    mas.SetHead(model.BuildingNameCH, model.BuildingNameCH, StringHelper.CutString(des, 100));
                }
                else { model = new Bpams_House(); }
            }
            else { model = new Bpams_House(); }
        }
    }

    public string GetImages(string id)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append("<ul class='listPic4'>");

        var list = ImageBll.I.GetImages("Sale", id);

        foreach (var item in list)
        {
            sb.Append("<li>");
            sb.Append("<a href='#' class='img'><img src='userfiles/sale/default/" + item.Img + "'/></a>");
            sb.Append("</li>");
        }

        sb.Append("</ul>");

        return sb.ToString();
    }
    #endregion
}